<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: space_blog.php 13208 2009-08-20 06:31:35Z liguode $
*/

if(!defined('IN_UCHOME')) {
	exit('Access Denied');
}


$page = empty($_GET['page'])?1:intval($_GET['page']);
if($page<1) $page=1;
$picid = empty($_GET['id'])?0:intval($_GET['id']);

//分类文件
include_once (S_ROOT . './source/function_product.php');


if($picid) {
	$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('product')." b 		
		WHERE b.picid='$picid'");
	
	$pic[thumbpath] = empty($pic[thumbpath])?$pic[filepath] . ".thumb.jpg":$pic[thumbpath];
	
	$pic = $_SGLOBAL['db']->fetch_array($query);
	echo "<div style='padding:0 5px;text-align:right;'><a href='javascript:;' onclick='menuHide();' >关闭</a></div>";
	echo "<img src='".$pic[filepath]."'/>";
	die();

} else {
	//分页
	$perpage = 100;
	$perpage = mob_perpage($perpage);
	
	$start = ($page-1)*$perpage;

	//检查开始数
	ckstart($start, $perpage);

	//摘要截取
	$summarylen = 300;

	$classarr = array();
	$list = array();
	$userlist = array();
	$count = $pricount = 0;

	$ordersql = 'b.dateline';

	

	//处理查询
	$f_index = '';

	$wheresql = "";
	$theurl = "space.php?do=product";
	
	$cat = $_GET[cat];
	$subcat = $_GET[subcat];
	if(!empty($cat)){
		$wheresql .= "where cat= '".$cat."'";
		$theurl .= "&cat=".$cat;
	}

	if(!empty($subcat)){
		$wheresql .= " and subcat= '".$subcat."'";
		$theurl .= "&subcat=".$subcat;
	}
	echo "SELECT COUNT(*) FROM ".tname('product')." b  $wheresql";
	
	$count = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM ".tname('product')." b  $wheresql"),0);

	if($count) {
		$query = $_SGLOBAL['db']->query("SELECT * FROM ".tname('product')." $wheresql  LIMIT $start,$perpage");
		while ($value = $_SGLOBAL['db']->fetch_array($query)) {
			$pic[thumbpath] = empty($pic[thumbpath])?$pic[filepath] . ".thumb.jpg":$pic[thumbpath];
			$list[] = $value;
		}
	}

	//分页
	$multi = multi($count, $perpage, $page, $theurl);

	//实名
	realname_get();

	$_TPL['css'] = 'blog';
	if($_GET[o]){
		$list_m = array_chunk($list,3);
//		print_r($list_m);
		include_once template("space_product_list1");
		
	}else{
		include_once template("space_product_list");		
	}
	
}

?>